layui.use(['laypage', 'layer','upload'], function(){
    var laypage = layui.laypage
        ,$ = layui.jquery
        ,upload = layui.upload;
    laypage.render({
        elem: 'data_fill_page'
        ,count: 1000
        ,layout: ['limit', 'prev', 'page', 'next']
    });
    laypage.render({
        elem: 'data_research_page'
        ,count: 1000
        ,layout: ['limit', 'prev', 'page', 'next']
    });

    $('#import-btn').on('click', function(){//执行弹框事件
        layerActive.openLayerImport();
    });

    //触发弹窗事件
    var layerActive = {//弹框方法
        openLayerImport:function(){//催报信息弹窗
            layer.open({
                type: 1
                ,title: '导入催报信息' //不显示标题栏
                ,closeBtn: true
                ,area: '500px;'
                ,shade: 0.5
                ,id: 'layerImport' //设定一个id，防止重复弹出
                ,btn: ['导入数据', '取消']
                ,btnAlign: 'c'
                ,moveType: 1 //拖拽模式，0或者1
                ,content: $(".layer-import").html()
                ,success: function(layero){
                    var btn = layero.find('.layui-layer-btn');
                    btn.find('.layui-layer-btn0').attr({
                        href: 'manage/reportImport.html'
                        ,target: '_blank'
                    });
                }
            });

            //拖拽上传
            upload.render({
                elem: '.import-upload'
                ,url: 'XXX'
                ,accept: 'file' //普通文件
                ,done: function(res){
                    console.log(res)
                }
            });
        },

        urgeReport: function(){//催报
            layer.open({
                type: 1
                ,title: '催报' //不显示标题栏
                ,closeBtn: true
                ,area: '500px;'
                ,shade: 0.5
                ,id: 'layui-urgereport' //设定一个id，防止重复弹出
                ,btn: ['点击催报', '取消']
                ,btnAlign: 'c'
                ,moveType: 1 //拖拽模式，0或者1
                ,content: $(".layer-urgereport").html()
                ,success: function(layero){
                    // console.log('催报成功')
                }
            });
        },
        openCollectDetail:function(){
            window.location = 'manage/collectDetail.html';
        },
        gotoResearchFillIn:function(){
            window.location = 'manage/researchFillIn.html';
        },
        gotoAddResearchFillIn:function(){
            window.location = 'manage/addResearchFillIn.html';
        }
    };

    $('#data_filltable .layui-btn').on('click', function(){//执行弹框事件
        var othis = $(this), method = othis.data('method');
        layerActive[method] ? layerActive[method].call(this, othis) : '';
    });
    $('#data_researchtable .layui-btn').on('click', function(){//执行弹框事件
        var othis = $(this), method = othis.data('method');
        console.log(method);
        layerActive[method] ? layerActive[method].call(this, othis) : '';
    });
    $(".add-import-btn").on('click', function(){//进入新增调查对象
        layerActive.gotoAddResearchFillIn();
    });

});





